import request from '@/utils/request'

import type { responseDataType, listDataType } from './model'
import type { VillageInfo } from './village.model'
const baseRequest = request.init(import.meta.env.VITE_APP_BASE_API)

// 获取乡村信息
export function villageList() {
  return baseRequest.get<any, responseDataType<listDataType<VillageInfo>>>('api/auth/village')
}

// 新增乡村
export function addVillage(data: VillageInfo) {
  return baseRequest.post<any, responseDataType<any>>('api/auth/village', data)
}

// 修改乡村
export function updateVillage(data: VillageInfo) {
  return baseRequest.put<any, responseDataType<any>>('api/auth/village', data)
}

// 删除
export function deleteVillage(id: number) {
  return baseRequest.delete<any, responseDataType<any>>(`api/auth/village/${id}`)
}
